clear all

*Note - Code used to generate alternative meta analysis used in the appendix
use "metadata_alt.dta"

metareg beta prepost quasi s2 s3 s4 s5 s6, wsse(se) random

gen metab=.
replace metab=_b[prepost] in 1
replace metab=_b[quasi] in 2
gen metase=.
replace metase=_se[prepost] in 1
replace metase=_se[quasi] in 2
gen metalo=metab-1.96*se
gen metahi=metab+1.96*se
gen metax=_n
replace metax=. if _n>2

*graph of treatment effects
gen lo=beta-1.96*se
gen hi=beta+1.96*se

gen x=study-.25
gen w=study+.25

twoway (scatter beta study if prepost==1, msymbol(S) mcol(black)) (rcap lo hi study if prepost==1, lcol(black)) ///
	(scatter beta x if design=="Post", msymbol(O) mcol(gs10)) (rcap lo hi x if design=="Post", lcol(gs10)) ///
	(scatter beta w if quasi==1, msymbol(T) mcol(sky)) (rcap lo hi w if quasi==1, yline(0) lcol(sky) ///
	xtitle(Study) xsc(range(0.5 6.5) titlegap(2)) ytitle("Treatment Effect") ylab(-.15(.15).3) ///
	subtitle("Treatment Effects by Study and Design") ///
	legend(order(1 "Posttest" 3 "Pretest" 5 "Quasi")) saving(coefs.gph, replace)) 

*graph of meta effects
twoway (scatter metab metax) (rcap metalo metahi metax, yline(0) ///
	ylab(-.15(.15).3) xsc(range(.5 2.5) titlegap(2)) legend(off) ///
	subtitle("Meta-Analytic Effect") ///
	xlab(1 "Prepost" 2 "Quasi") xtitle("Design") ytitle("Design Coefficient") ///
	fxsize(50) saving(meta.gph, replace))
	
graph combine coefs.gph meta.gph
